<?php

namespace JLPay\Models\BaseData;

use JLPay\Models\BaseRequest;

/**
 * 分支行信息查询请求
 */
class BankBranchListRequest extends BaseRequest
{
    /**
     * API接口路径
     */
    public const API_URL = '/open/base/data/bank-branch/list';

    protected ?string $branchCode = null;
    protected ?string $branchName = null;
    protected ?string $bankCode = null;
    protected ?int $limit = null;
    protected ?int $offset = null;

    /**
     * 设置银行分支行行号
     *
     * @param string $branchCode
     * @return self
     */
    public function setBranchCode(string $branchCode): self
    {
        $this->branchCode = $branchCode;
        return $this;
    }

    /**
     * 设置银行分支行名称
     *
     * @param string $branchName
     * @return self
     */
    public function setBranchName(string $branchName): self
    {
        $this->branchName = $branchName;
        return $this;
    }

    /**
     * 设置银行总行行号
     *
     * @param string $bankCode
     * @return self
     */
    public function setBankCode(string $bankCode): self
    {
        $this->bankCode = $bankCode;
        return $this;
    }

    /**
     * 设置每页记录数
     *
     * @param int $limit
     * @return self
     */
    public function setLimit(int $limit): self
    {
        $this->limit = $limit;
        return $this;
    }

    /**
     * 设置偏移量
     *
     * @param int $offset 偏移量，pageSize = offset / limit + 1，示例值：如果limit为10，则第二页offset传11
     * @return self
     */
    public function setOffset(int $offset): self
    {
        $this->offset = $offset;
        return $this;
    }

    /**
     * 转换为数组
     *
     * @return array
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        
        if ($this->branchCode !== null) {
            $data['branch_code'] = $this->branchCode;
        }
        if ($this->branchName !== null) {
            $data['branch_name'] = $this->branchName;
        }
        if ($this->bankCode !== null) {
            $data['bank_code'] = $this->bankCode;
        }
        if ($this->limit !== null) {
            $data['limit'] = $this->limit;
        }
        if ($this->offset !== null) {
            $data['offset'] = $this->offset;
        }
        
        return $data;
    }
} 